<%--
  User: zhouyanchao
  Date: 2017/10/16
--%>
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html>
<head>
	<base href="${BaseContext}">
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Title</title>

	<link rel="stylesheet" type="text/css" href="static/Css/bootstrap.css" />
	<link rel="stylesheet" type="text/css" href="static/Css/bootstrap-responsive.css" />
	<link rel="stylesheet" type="text/css" href="static/Css/style.css" />
	<script type="text/javascript" src="static/Js/jquery.js"></script>
	<script type="text/javascript" src="static/Js/bootstrap.js"></script>
	<style type="text/css">
		body {
			padding-top: 40px;
			padding-bottom: 40px;
			background-color: #f5f5f5;
		}

		.form-signin {
			max-width: 300px;
			padding: 19px 29px 29px;
			margin: 0 auto 20px;
			background-color: #fff;
			border: 1px solid #e5e5e5;
			-webkit-border-radius: 5px;
			-moz-border-radius: 5px;
			border-radius: 5px;
			-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
			-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
			box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
		}

		.form-signin .form-signin-heading,
		.form-signin .checkbox {
			margin-bottom: 10px;
		}

		.form-signin input[type="text"],
		.form-signin input[type="password"] {
			font-size: 16px;
			height: auto;
			margin-bottom: 15px;
			padding: 7px 9px;
		}

	</style>
</head>
<body>

<form class="form-signin" method="post" action="login.action" id="loginForm">
	<h2 class="form-signin-heading">&nbsp;&nbsp;&nbsp;登录系统</h2>
	<input type="text" name="loginUser" class="input-block-level" placeholder="账号">
	<input type="password" name="loginPwd" class="input-block-level" placeholder="密码">
	<input type="text" name="verify" class="input-medium" placeholder="验证码">
	<img src="loginverify.action" style="margin-bottom: 15px;" id="verifyImg">

	<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button class="btn btn-large btn-primary" type="button" id="subBtn">登录</button></p>
</form>

<div>
	<s:fielderror></s:fielderror>

	<s:fielderror name="loginName"></s:fielderror>

</div>

<script>
	$(function () {
		$('#verifyImg').click(function () {
			//点击刷新验证码
			refreshImg();
		});

		function refreshImg() {
			$("#verifyImg").attr('src','loginverify.action?r='+new Date());
		}

		//数据校验省略

		$('#subBtn').click(function () {
			$.post('login.action',$('#loginForm').serialize(),function (result) {
				if(result.success){
					//登录成功，跳转
					window.location.href='home.action';
				}else{
					//登录失败
					alert(result.message);
					refreshImg();
				}
			},'json');
		});

	});
</script>
</body>
</html>
